package com.douqu.game.main.server.entity;

import com.bean.core.buffer.ByteBuffer;
import com.douqu.game.core.database.model.PlayerModel;
import com.douqu.game.core.e.E_WorldMapKillRankType;
import com.douqu.game.core.entity.Player;
import com.douqu.game.core.entity.ext.ChallengeInfo;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-02-06 10:06
 */
public class RankPlayerDetail {

    private String objectIndex;

    private String name;

    private int camp;

    private String avatar;

    private int master;

    private int totalIntegral;

    private String serverName;

    private int lv;

    public RankPlayerDetail(Player player)
    {
        this.objectIndex = player.getObjectIndex();
        this.lv = player.getLv();
        update(player);
    }

    public RankPlayerDetail(PlayerModel player)
    {
        this.objectIndex = player.getObjectIndex();
        this.lv = player.getLevel();
        update(player);
    }

    public void update(Player player)
    {
        this.name = player.name;
        this.camp = player.camp;
        this.avatar = player.avatar;
        this.master = player.master;
        this.lv = player.getLv();
        this.totalIntegral = player.getWorldMapKillData().getTotalValue(E_WorldMapKillRankType.CURRENT_WEEK_RANK);
    }

    public void update(PlayerModel player)
    {
        this.name = player.getName();
        this.camp = player.getCamp();
        this.avatar = player.getAvatar();
        this.master = player.getMaster();
        this.lv = player.getLevel();

        ChallengeInfo challengeInfo = new ChallengeInfo(null);
        if(player.getChallengeInfo() != null)
        {
            ByteBuffer buffer = new ByteBuffer(player.getChallengeInfo());
            challengeInfo.loadFrom(buffer);
            this.totalIntegral = challengeInfo.getWorldMapTaskData().getKillData().getTotalValue(E_WorldMapKillRankType.CURRENT_WEEK_RANK);
        }
//        Player player1 = new Player(player);
//        this.totalIntegral = player1.getWorldMapKillData().getTotalValue(E_WorldMapKillRankType.CURRENT_WEEK_RANK);
    }

    public String getObjectIndex() {
        return objectIndex;
    }

    public void setObjectIndex(String objectIndex) {
        this.objectIndex = objectIndex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCamp() {
        return camp;
    }

    public void setCamp(int camp) {
        this.camp = camp;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public int getMaster() {
        return master;
    }

    public void setMaster(int master) {
        this.master = master;
    }

    public int getTotalIntegral() {
        return totalIntegral;
    }

    public void setTotalIntegral(int totalIntegral) {
        this.totalIntegral = totalIntegral;
    }

    public String getServerName() {
        return serverName;
    }

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    public int getLv() {
        return lv;
    }

    public void setLv(int lv) {
        this.lv = lv;
    }
}
